/**
 * @author jstone
 */

var SnippetView = new KONtx.Class({
 	ClassName: 'MyCustomSnippetView',
	
	Extends: KONtx.system.SnippetView,
	
	config: {
		prefix: ""
	},
	
	initView: function() {
    if (this.config.data.mode == "record") {
		  this.config.prefix= "My Record: ";
    } else {
      this.config.prefix = "My Rank: ";
    }
	},
	
	createView: function() {
   /*
   this.controls.bgImage = new KONtx.element.Image({
      src: "image/960x540/ficon.png",
      styles: {
        hOffset: this.width - 94,
        vOffset: KONtx.utility.scale(-8),
      }
    }).aspectSizeMin(100).appendTo(this);
    */
    this.controls.bgImage = new KONtx.element.Image({
      src: "image/960x540/nfllogo.png",
      styles: {
        hOffset: this.width - 80,
        vOffset: KONtx.utility.scale(0),
      }
    }).aspectSizeMax(80).appendTo(this);

   this.controls.bgImage = new KONtx.element.Image({
      src: "image/960x540/sports.png",
      styles: {
        hOffset: KONtx.utility.scale(11),
        vOffset: KONtx.utility.scale(26),
      }
    }).aspectSizeMax(130).appendTo(this);
/*
		this.controls.apptitle = new KONtx.element.Text({
      label: 'Football',
      styles: {
        hOffset: KONtx.utility.scale(120),
        vOffset: KONtx.utility.scale(22),
        fontSize: '18px',
        fontWeight: 'bold',
        color: '#66FF00'
      }
    }).appendTo(this);
*/        
		this.controls.counter = new KONtx.element.Text({
      label: this.config.counterPrefix + this.selected_count,
      styles: {
        hAlign: 'left',
        vOffset: KONtx.utility.scale(50),
        fontSize:  KONtx.utility.scale(16),
        fontSize: KONtx.utility.scale(14),
        fontWeight: 'bold',
        color: '#FF66FF'
      }
    }).appendTo(this);

	},
	
	updateView: function() {
    var myUrl = new URL;
    if (this.config.data.mode == "record") {
      myUrl.location = "http://" + host + "/record.php";
    } else {
      myUrl.location = "http://" + host + "/rank.php";
    }
    
    var result = myUrl.fetch();
		this.controls.counter.setText( "    " + this.config.prefix + result); 
	}
});
